﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

using AMS.Business;

namespace AMS
{
    public partial class frmLoadRequest : BaseForm, IUpdatableForm
    {
        public frmLoadRequest()
        {
            InitializeComponent();

            base.isSingleton = true;
        }

        #region Button Events

        private void btnCancel_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void btnOK_Click(object sender, EventArgs e)
        {
            if (txtRequestNumber.Text.Length == 0)
            {
                MessageBox.Show("Vul een aanvraagnummer in", "Aanvraag laden");
            }
            else
            {
                Int32 requestNumber;
                if (!Int32.TryParse(txtRequestNumber.Text, out requestNumber))
                {
                    MessageBox.Show("Het aanvraagnummer is niet nummeriek", "Aanvraag laden");
                }
                else
                {
                    RequestClass request = new RequestClass();
                    if (request.CheckRequest(requestNumber))
                    {
                        Cursor defaultCursor = Cursor;
                        Cursor = Cursors.WaitCursor;

                        base.internalFormManager.ShowForm(FormTypes.Request, requestNumber);
                        this.Close();

                        Cursor = defaultCursor;
                    }
                    else
                    {
                        MessageBox.Show("Aanvraag bestaat niet.");
                    }
                }
            }
        }
        #endregion

        #region IUpdatableForm Members

        void IUpdatableForm.RefreshData()
        {
            // Ignore
        }

        #endregion
    }
}
